<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>    
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>商城产品页面</title>
    <%@include file="../common/header.jsp" %>
</head>
<body>
<%@include file="../common/top.jsp" %>
<form id="mainFrame" action="${pathUrl}/home/order/confrimOrder" method="post">
<input type="hidden" name="goodsId" value="${goods.id}">
<div class="section" style="margin-top: 5px;">
    <div class="wrapper clearfix">
        <div class="wrap-box">
                <div class="goods-box clearfix">
                    <div class="goods-pic">
                        <div class="pic-box">
                            <div class="pic-preview">
                                <span class="jqzoom">
                                    <img  onerror="this.src='${pathUrl }/public/images/nopic.png'"  src="${pathUrl}${goods.goodsImg}" alt="">
                                </span>
                            </div>
                        </div>
                    </div>
                    <!--商品信息-->
                    <div class="goods-spec">
                        <h1>${goods.goodsName}</h1>
                        <div class="spec-box">
                            <dl>
                                <dt>货号</dt>
                                <dd id="commodityGoodsNo">${goods.goodsSn}</dd>
                            </dl>
                            <dl>
                                <dt>市场价</dt>
                                <dd><strong id="commodityMarketPrice">¥${goods.marketPrice}</strong></dd>
                            </dl>
                            <dl>
                                <dt>销售价</dt>
                                <dd><em class="price" id="commoditySellPrice">¥${goods.sellPrice}</em></dd>
                            </dl>
                        </div>

                        <div class="spec-box">
                            <dl>
                                <dt>购买数量</dt>
                                <dd>
                                    <div class="stock-box" style="line-height: 30px;">
                                       <strong><input type="text" value="1" name="go_num" id="go_num" /></strong>
                                    </div>
                                    <span class="stock-txt">
                                        库存<em id="commodityStockNum">${goods.goodsNumber}</em>件
                                    </span>
                                </dd>
                            </dl>
                            <dl>
                                <dd>
                                    <div class="btn-buy" id="buyButton">
                                        <button class="buy" type="submit" >立即购买</button>
                                        <button class="add" type="button" onclick="submitCart()">加入购物车</button>
                                    </div>
                                </dd>
                            </dl>
                        </div>
                    </div>
                    <!--/商品信息-->
                </div>
        </div>
    </div>
    <div id="goodsTabs" class="goods-tab bg-wrap">
        <!--选项卡-->
        <div id="tabHead" class="tab-head">
            <ul>
                <li>
                    <a class="selected" href="javascript:;">商品介绍</a>
                </li>
            </ul>
        </div>
        <!--/选项卡-->
        <!--选项内容-->
        <div class="tab-content entry" style="display:block;">
          	${goods.description}
        </div>
    </div>
</div>
</form>
<div class="section qitian-main">
    <img src="${pathUrl}/public/images/qitian.png">
</div>
<div class="footer-copyright">
    <p>软信商城©2013-2017 软信大学版权所有 京ICP备17017089号 京公网安备11000002000006号</p>
</div>
</body>
<script type="text/javascript">
 	function submitCart(){
 		var url="${pathUrl}/home/cart/submitCart";
 		var id="${goods.id}";
 		var goNum=$("#go_num").val();
		$.post(url,{"goodsId":id,"goodsNum":goNum},function(result){
			if(result.status==1){
				alert("加入购物车成功");
			}else if(result.status==0){
				alert("操作失败");
			}else if(result.status==-1){
				alert("库存不足");
			}else {
				alert("请先登录");
				window.location.href="${pathUrl}/home/index/login";
			}
		});
 	}
</script>
</html>